﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using Entity;
using Utility;

namespace DAL
{
    public class ServiceDAO
    {
        public static int InsertService(AppointmentService service)
        {
            string sql = SqlSentence.insertService;
            SqlParameter[] parameter =
            {
                new SqlParameter("@ServiceName", service.ServiceName),
                new SqlParameter("@TimeBuckets", service.TimeBuckets),
                new SqlParameter("@DirectorId", service.DirectorId),
                new SqlParameter("@Introduction", service.Introduction),
                new SqlParameter("@PerMultiTime", service.PerMultiTime),
                new SqlParameter("@MultiNum", service.MultiNum)                           
            };
            return SqlHelper.ExecteNonQueryText(sql, parameter);
        }

        public static int UpdateService(AppointmentService service)
        {
            string sql = SqlSentence.updateService;
            SqlParameter[] parameter =
            {
                new SqlParameter("@ServiceId", service.ServiceId),          
                new SqlParameter("@ServiceName", service.ServiceName),              
                new SqlParameter("@Introduction", service.Introduction),
                new SqlParameter("@MultiNum", service.MultiNum),                           
                new SqlParameter("@IsActive", service.IsActive)                           
            };
            return SqlHelper.ExecteNonQueryText(sql, parameter);
        }

        public static DataTable GetAllActiveService()
        {
            string sql = SqlSentence.getAllActiveService;           
            return SqlHelper.GetSingleTableText(sql, null);
        }

        public static DataTable GetServicesForDirector(string userId)
        {
            string sql = SqlSentence.getServicesForDirector;
            SqlParameter[] parameter =
            {
                new SqlParameter("@UserId", userId)
            };
            return SqlHelper.GetSingleTableText(sql, parameter);
        }

        public static DataTable GetServiceByServiceId(int serviceId)
        {
            string sql = SqlSentence.getServiceByServiceId;
            SqlParameter[] parameter =
            {
                new SqlParameter("@ServiceId", serviceId)
            };
            return SqlHelper.GetSingleTableText(sql, parameter);
        }
        
    }
}
